/**
 * @FileDescription 战时标绘api
 */
import { chemical_server as request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(response: ResultType) {
  if (response.result.resultCode == '000000') {
    return response.data
  }
  throw new Error()
}

// 根据id查询标绘图
export const queryLayerInfo = (params?: any) =>
  request.get(`/bht/queryBhtInfo`, { params }).then((res) => adapter(res as any))

// 根据企业id查询15、标绘位置信息表
export const queryLayerMarkerInfo = (params?: any) =>
  request.get(`/bh-wzxxb/queryBhWzxxbInfo`, { params }).then((res) => adapter(res as any))

// 新增或修改标绘图
export const updateLayerInfo = (params?: any) =>
  request.post(`/bht/insertOrUpdate`, params).then((res) => adapter(res as any))

// 根据消防车类型代码 查询字典代码表
export const queryCarTypeDic = (params?: any) =>
  request.get(`/zd-zdmc/queryZdZdmcInfo`, { params }).then((res) => adapter(res as any))

// 新增或修改15、标绘位置信息表
export const insertUpdateMarkerInfo = (params?: any) =>
  request.post(`/bh-wzxxb/insertOrUpdate`, params).then((res) => adapter(res as any))

// 新增或修改附件信息-标绘
export const insertUpdatePlotFile = (params?: any) =>
  request.post(`/fjxx/insertOrUpdateByBh`, params).then((res) => adapter(res as any))

// 根据企业id和标绘图id删除所有标绘位置
export const deleteLayerAllMarker = (params?: any) =>
  request.get(`/bh-wzxxb/deleteAll`, { params }).then((res) => adapter(res as any))
